package es.app.acciones;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.actions.DispatchAction;

import es.app.constantes.Constantes;

public class AppSHSAction extends DispatchAction {
	
	protected boolean hayErroresEnFormulario(final HttpServletRequest request){
		ActionMessages errores = getErrors(request);
		return errores!=null && errores.size()>0;
	}
	
	protected void anadirError(final HttpServletRequest request, final String campo, final String key, final Object[] values){
		ActionMessages errores = getErrors(request);
		errores.add(campo, new ActionMessage(key,values));
		saveErrors(request, errores);
	}
	
	protected void setOpcionMenu(HttpServletRequest request, final int opcionMenu){
		HttpSession sesion = request.getSession();
		sesion.setAttribute(Constantes.OPCION_MENU, opcionMenu);
		
	}

}
